<script type="text/javascript" src="<%=resource%>/xlnetacc/md5-min.js"></script>
<!-- <script type="text/javascript" src="<%=resource%>/xlnetacc/sha1-min.js"></script> -->
<script type="text/javascript" src="<%=resource%>/xlnetacc/rsa.js"></script>

<script type="text/javascript">
	function onchange_rsa(id) {
		cbi_d_update(id);

		var password = document.getElementById('cbid.xlnetacc.general.password').value;
		if ( password == "" ) {
			document.getElementById('cbid.xlnetacc.general.encrypt').value = "";
		} else {
			var kn = 'AC69F5CCC8BDE47CD3D371603748378C9CFAD2938A6B021E0E191013975AD683F5CBF9ADE8BD7D46B4D2EC2D78AF146F1DD2D50DC51446BB8880B8CE88D476694DFC60594393BEEFAA16F5DBCEBE22F89D640F5336E42F587DC4AFEDEFEAC36CF007009CCCE5C1ACB4FF06FBA69802A8085C2C54BADD0597FC83E6870F1E36FD';
			var ke = '010001';
			var rsa = new RSAKey();
			rsa.setPublic(kn, ke);

			var cryptpwd = rsa.encrypt(hex_md5(password));
			document.getElementById('cbid.xlnetacc.general.encrypt').value = cryptpwd.toUpperCase();
		}
	}
</script>

<%+cbi/valueheader%>
	<input data-update="change"<%=
		attr("id", cbid) ..
		attr("name", cbid) ..
		attr("type", self.password and "password" or "text") ..
		attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
		attr("value", self:cfgvalue(section) or self.default) ..
		ifattr(self.size, "size") ..
		ifattr(self.placeholder, "placeholder") ..
		ifattr(self.readonly, "readonly") ..
		ifattr(self.maxlength, "maxlength") ..
		ifattr(self.datatype, "data-type", self.datatype) ..
		ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
		ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
		ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
	%> onchange="onchange_rsa(this.id)" />
	<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
<%+cbi/valuefooter%>
